﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain.Core.Specification;
using Domain.MainModule.Entities;

namespace Domain.MainModule.BillingInformations
{
    public class BillingInformationCUITSpecification: Specification<BillingInformation>
    {
        private string _CUIT;

        public BillingInformationCUITSpecification(string cuit)
        {
            this._CUIT = cuit;
        }

        public override System.Linq.Expressions.Expression<Func<BillingInformation, bool>> SatisfiedBy()
        {
            Specification<BillingInformation> spec = new TrueSpecification<BillingInformation>();

            spec &= new DirectSpecification<BillingInformation>(c => !string.IsNullOrEmpty(this._CUIT) 
                && c.CUIT.Contains(this._CUIT));

            return spec.SatisfiedBy();
        }

    }
}
